﻿@model IList<Shop.Page.Models.WaresPicture>
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>PagesManage</title>
    <link href="~/Content/BootStrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/BootStrap/css/bootstrap-theme.min.css" rel="stylesheet" />
    <link href="~/Content/BootStrap/css/docs.min.css" rel="stylesheet" />
    <link href="~/bootstrapvalidator-master/dist/css/bootstrapValidator.min.css" rel="stylesheet" />

    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Content/BootStrap/js/bootstrap.min.js"></script>
    <script src="~/Content/BootStrap/js/docs.min.js"></script>
    <script src="~/bootstrapvalidator-master/dist/js/bootstrapValidator.min.js"></script>
    <script src="~/bootstrapvalidator-master/dist/js/language/zh_CN.js"></script>
</head>
<body>
    <a href="AddPage" class="btn btn-primary">添加</a>
    <h3>
        首页图片轮播设置
    </h3>
    <table class="table table-bordered table-striped table-hover">
        <tr>
            <td>ID</td>
            <td>关联商品名</td>
            <td>关联商品ID</td>
            <td>图片</td>
            <td>操作</td>
        </tr>
        @foreach (var item in Model)
        {
            if (item.Type == 0)
            {
                <tr>
                    <td>@item.HID</td>
                    <td>@item.WName</td>
                    <td>@item.WID</td>
                    <td>
                        <img src="@item.Url" style="width:60px;height:40px;"/>
                    </td>
                    <td>
                        <a href="UpdatePage-@item.HID" class="btn btn-default">修改</a>
                        <input type="button" class="btn btn-default" value="删除" onclick="del('@item.HID');" />
                        <input type="button" class="btn btn-default" value="置顶" onclick="order('@item.HID');" />
                    </td>
                </tr>
            }
        }
    </table>
    <h3>
        首页侧边图
    </h3>
    <table class="table table-bordered table-striped table-hover">
        <tr>
            <td>ID</td>
            <td>关联商品名</td>
            <td>关联商品ID</td>
            <td>图片</td>
            <td>操作</td>
        </tr>
        @foreach (var item in Model)
        {
            if (item.Type == 1)
            {
                <tr>
                    <td>@item.HID</td>
                    <td>@item.WName</td>
                    <td>@item.WID</td>
                    <td>
                        <img src="@item.Url" style="width:60px;height:40px;" />
                    </td>
                    <td>
                        <a href="UpdatePage-@item.HID" class="btn btn-default">修改</a>
                        <input type="button" class="btn btn-default" value="删除" onclick="del('@item.HID');" />
                        <input type="button" class="btn btn-default" value="置顶" onclick="order('@item.HID');" />
                    </td>
                </tr>
            }
        }
    </table>
    <script type="text/javascript">
        function order(HID) {
           var gnl = confirm("确定要置顶吗?");
            if (gnl == true) {
                $.ajax({
                    url: '@Url.Action("OrderPage", "Page")',
                    type: 'post',
                    dataType: 'text',
                    async: false,
                    data: { HID: HID },
                    success: function (data) {
                        if (data == "NO") {
                            alert("置顶失败");
                        }
                        else {
                            alert("置顶成功");
                            window.location.reload();
                        }
                    }
                });
            }
        }
        function del (HID)
        {
            var gnl = confirm("确定要删除?");
            if (gnl == true) {
                $.ajax({
                    url: '@Url.Action("DelPage", "Page")',
                    type: 'post',
                    dataType: 'text',
                    async: false,
                    data: { HID: HID },
                    success: function (data) {
                        if (data == "NO") {
                            alert("删除失败");
                        }
                        else {
                            alert("删除成功");
                            window.location.reload();
                        }
                    }
                });
            }
        }
    </script>
</body>
</html>
